package com.yunpuvip.sachet.controller;

import com.yunpuvip.sachet.biz.entity.Sysparam;
import com.yunpuvip.sachet.biz.model.params.SysparamParam;
import com.yunpuvip.sachet.biz.service.SysparamService;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.core.reqres.response.ResponseData;
import com.yunpuvip.sachet.modular.page.LayuiPageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * 系统参数控制器
 *
 * @author wushaohong
 * @Date 2019-08-10 09:46:09
 */
@Controller
@RequestMapping("/sysparam")
public class SysparamController extends BaseController {

    private String PREFIX = "/modular/sysparam";

    @Autowired
    private SysparamService sysparamService;

    /**
     * 跳转到主页面
     *
     * @author wushaohong
     * @Date 2019-08-10
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "/sysparam.html";
    }

    /**
     * 新增页面
     *
     * @author wushaohong
     * @Date 2019-08-10
     */
    @RequestMapping("/add")
    public String add() {
        return PREFIX + "/sysparam_add.html";
    }

    /**
     * 编辑页面
     *
     * @author wushaohong
     * @Date 2019-08-10
     */
    @RequestMapping("/edit")
    public String edit() {
        return PREFIX + "/sysparam_edit.html";
    }

    /**
     * 新增接口
     *
     * @author wushaohong
     * @Date 2019-08-10
     */
    @RequestMapping("/addItem")
    @ResponseBody
    public ResponseData addItem(SysparamParam sysparamParam) {
        this.sysparamService.add(sysparamParam);
        return ResponseData.success();
    }

    /**
     * 编辑接口
     *
     * @author wushaohong
     * @Date 2019-08-10
     */
    @RequestMapping("/editItem")
    @ResponseBody
    public ResponseData editItem(SysparamParam sysparamParam) {
        this.sysparamService.update(sysparamParam);
        return ResponseData.success();
    }

    /**
     * 删除接口
     *
     * @author wushaohong
     * @Date 2019-08-10
     */
    @RequestMapping("/delete")
    @ResponseBody
    public ResponseData delete(SysparamParam sysparamParam) {
        this.sysparamService.delete(sysparamParam);
        return ResponseData.success();
    }

    /**
     * 查看详情接口
     *
     * @author wushaohong
     * @Date 2019-08-10
     */
    @RequestMapping("/detail")
    @ResponseBody
    public ResponseData detail(SysparamParam sysparamParam) {
        Sysparam detail = this.sysparamService.getById(sysparamParam.getId());
        return ResponseData.success(detail);
    }

    /**
     * 查询列表
     *
     * @author wushaohong
     * @Date 2019-08-10
     */
    @ResponseBody
    @RequestMapping("/list")
    public LayuiPageInfo list(SysparamParam sysparamParam) {
        return this.sysparamService.findPageBySpec(sysparamParam);
    }

}


